﻿CREATE PROCEDURE [ServiceEngine].ListRuntimeEventDataForOperationID
	@OperationID uniqueidentifier
AS
BEGIN
	SET NOCOUNT ON
	SELECT DISTINCT rse.RuntimeServerID, rse.EndpointID, ov.OperationID
	FROM ServiceEngine.OperationVersions ov
		INNER JOIN ServiceEngine.Endpoints_AssociatedOperations eao ON eao.OperationVersionID = ov.OperationVersionID
		INNER JOIN ServiceEngine.RuntimeServers_Endpoints rse ON eao.EndpointID = rse.EndpointID
	WHERE ov.OperationID = @OperationID
	UNION
	SELECT DISTINCT rse.RuntimeServerID, rse.EndpointID, ov.OperationID
	FROM ServiceEngine.OperationVersions ov
		INNER JOIN ServiceEngine.Endpoints_PublishedOperations epo ON epo.OperationVersionID = ov.OperationVersionID
		INNER JOIN ServiceEngine.RuntimeServers_Endpoints rse ON epo.EndpointID = rse.EndpointID
	WHERE ov.OperationID = @OperationID
END


